﻿using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

public partial class _Default : System.Web.UI.Page 
{
    List<string> ListCity = new List<string>();
    List<string> ListCityInfo = new List<string>();
    List<string> ListItemsDesciption = new List<string>();
    List<string> ListItemsTitle = new List<string>();
    List<string> ListItemsLink = new List<string>();
    List<string> ListItems = new List<string>();
    
    ServiceReference.ServiceSoapClient obj = new ServiceReference.ServiceSoapClient();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            
            ListCity = obj.ListCity();
            for (int i = 0; i < ListCity.Count; i++)
            {
                DropDownListCities.Items.Add(ListCity[i]);
            }
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string choosingCity= DropDownListCities.SelectedItem.Text;
        try
        {
            ListCityInfo = obj.ListCityInfo(choosingCity);    
            ListItems = obj.ListItems(choosingCity);
            TableInfo.Rows[0].Cells[0].Text = "<a href='" + ListCityInfo[2] + "' style = 'font-size:20px; color:#000000; text-decoration:none;'><b>" + ListCityInfo[0] + "</b></a>";
            TableInfo.Rows[1].Cells[0].Text = "<hr style='color:#cccccc' width='100%'>";
                
            for (int i = 3, j = 0; j < ListItems.Count;)
            {
                TableInfo.Rows[i++].Cells[0].Text = "<a href='" + ListItems[j + 1] + "' style = 'font-size:14px; color: blue; text-decoration:none;'><b>" + ListItems[j] + "</b></a>";
                j += 2;
                TableInfo.Rows[i++].Cells[0].Text = "<div style='font-size:11px; '>" + ListItems[j++] + "</div>";
                TableInfo.Rows[i++].Cells[0].Text = ListItems[j++] + "<br /><br />";
                    
            }
        }
        catch
        {
            Response.Write("<script> Alert('Oops! Not available!!!')</script>");
        }
    }
}
